﻿using System;
using System.Data;
using System.Text;
using System.Data.SqlClient;
using Maticsoft.DBUtility;//Please add references
namespace EnterpriseFund.DAL
{
    /// <summary>
    /// 数据访问类:VTaxAuditPolicyEval
    /// </summary>
    public partial class VTaxAuditPolicyEval
    {
        public VTaxAuditPolicyEval()
        { }
        #region  BasicMethod

        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public EnterpriseFund.Model.VTaxAuditPolicyEval GetModel(string FTaxAuditId)
        {

            StringBuilder strSql = new StringBuilder();
            strSql.Append("select  top 1 FTaxAuditId,FEntityNo,FYear,FAllowanceClassNo,NSRDZDAH,RKRQ_Q,RKRQ_Z,NSRMC,FOldEnterprisePropNo,FOldFinancePropNo,FNewEnterprisePropNo,FNewFinancePropNo,FStatus,FNote,FPolicyNote,FIsReturn,FInsEmpNo,FInsDeptNo,FInsDate,FInsIP,FUpdEmplNo,FUpdDeptNo,FUpdDate,FUpdIP,FAllowanceName,FTaxClassAllowanceName,NSRBM,YBTJE from fund.v_TaxAuditPolicyEval ");
            strSql.Append(" where FTaxAuditId=@FTaxAuditId ");
            SqlParameter[] parameters = {
					new SqlParameter("@FTaxAuditId", SqlDbType.NVarChar,50)			};
            parameters[0].Value = FTaxAuditId;

            EnterpriseFund.Model.VTaxAuditPolicyEval model = new EnterpriseFund.Model.VTaxAuditPolicyEval();
            DataSet ds = DbHelperSQL.Query(strSql.ToString(), parameters);
            if (ds.Tables[0].Rows.Count > 0)
            {
                return DataRowToModel(ds.Tables[0].Rows[0]);
            }
            else
            {
                return null;
            }
        }


        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public EnterpriseFund.Model.VTaxAuditPolicyEval DataRowToModel(DataRow row)
        {
            EnterpriseFund.Model.VTaxAuditPolicyEval model = new EnterpriseFund.Model.VTaxAuditPolicyEval();
            if (row != null)
            {
                if (row["FTaxAuditId"] != null)
                {
                    model.FTaxAuditId = row["FTaxAuditId"].ToString();
                }
                if (row["FEntityNo"] != null)
                {
                    model.FEntityNo = row["FEntityNo"].ToString();
                }
                if (row["FAllowanceClassNo"] != null)
                {
                    model.FAllowanceClassNo = row["FAllowanceClassNo"].ToString();
                }
                if (row["NSRDZDAH"] != null && row["NSRDZDAH"].ToString() != "")
                {
                    model.NSRDZDAH = decimal.Parse(row["NSRDZDAH"].ToString());
                }
                if (row["RKRQ_Q"] != null && row["RKRQ_Q"].ToString() != "")
                {
                    model.RKRQ_Q = DateTime.Parse(row["RKRQ_Q"].ToString());
                }
                if (row["RKRQ_Z"] != null && row["RKRQ_Z"].ToString() != "")
                {
                    model.RKRQ_Z = DateTime.Parse(row["RKRQ_Z"].ToString());
                }
                if (row["NSRMC"] != null)
                {
                    model.NSRMC = row["NSRMC"].ToString();
                }
                if (row["FOldEnterprisePropNo"] != null)
                {
                    model.FOldEnterprisePropNo = row["FOldEnterprisePropNo"].ToString();
                }
                if (row["FOldFinancePropNo"] != null)
                {
                    model.FOldFinancePropNo = row["FOldFinancePropNo"].ToString();
                }
                if (row["FNewEnterprisePropNo"] != null)
                {
                    model.FNewEnterprisePropNo = row["FNewEnterprisePropNo"].ToString();
                }
                if (row["FNewFinancePropNo"] != null)
                {
                    model.FNewFinancePropNo = row["FNewFinancePropNo"].ToString();
                }
                if (row["FStatus"] != null)
                {
                    model.FStatus = row["FStatus"].ToString();
                }
                if (row["FNote"] != null)
                {
                    model.FNote = row["FNote"].ToString();
                }
                if (row["FPolicyNote"] != null)
                {
                    model.FPolicyNote = row["FPolicyNote"].ToString();
                }
                if (row["FIsReturn"] != null)
                {
                    model.FIsReturn = row["FIsReturn"].ToString();
                }
                if (row["FInsEmpNo"] != null)
                {
                    model.FInsEmpNo = row["FInsEmpNo"].ToString();
                }
                if (row["FInsDeptNo"] != null)
                {
                    model.FInsDeptNo = row["FInsDeptNo"].ToString();
                }
                if (row["FInsDate"] != null && row["FInsDate"].ToString() != "")
                {
                    model.FInsDate = DateTime.Parse(row["FInsDate"].ToString());
                }
                if (row["FInsIP"] != null)
                {
                    model.FInsIP = row["FInsIP"].ToString();
                }
                if (row["FUpdEmplNo"] != null)
                {
                    model.FUpdEmplNo = row["FUpdEmplNo"].ToString();
                }
                if (row["FUpdDeptNo"] != null)
                {
                    model.FUpdDeptNo = row["FUpdDeptNo"].ToString();
                }
                if (row["FUpdDate"] != null && row["FUpdDate"].ToString() != "")
                {
                    model.FUpdDate = DateTime.Parse(row["FUpdDate"].ToString());
                }
                if (row["FUpdIP"] != null)
                {
                    model.FUpdIP = row["FUpdIP"].ToString();
                }
                if (row["FAllowanceName"] != null)
                {
                    model.FAllowanceName = row["FAllowanceName"].ToString();
                }
                if (row["FTaxClassAllowanceName"] != null)
                {
                    model.FTaxClassAllowanceName = row["FTaxClassAllowanceName"].ToString();
                }
                if (row["FYear"] != null && row["FYear"].ToString() != "")
                {
                    model.FYear = decimal.Parse(row["FYear"].ToString());
                }
                if (row["FTaxClassAllowanceNo"] != null)
                {
                    model.FTaxClassAllowanceNo = row["FTaxClassAllowanceNo"].ToString();
                }
                if (row["FBaseAmount"] != null && row["FBaseAmount"].ToString() != "")
                {
                    model.FBaseAmount = decimal.Parse(row["FBaseAmount"].ToString());
                }
                if (row["FAllowanceType"] != null)
                {
                    model.FAllowanceType = row["FAllowanceType"].ToString();
                }
                if (row["FInnerRate"] != null && row["FInnerRate"].ToString() != "")
                {
                    model.FInnerRate = decimal.Parse(row["FInnerRate"].ToString());
                }
                if (row["FOuterRate"] != null && row["FOuterRate"].ToString() != "")
                {
                    model.FOuterRate = decimal.Parse(row["FOuterRate"].ToString());
                }
                if (row["FAllowanceAmount"] != null && row["FAllowanceAmount"].ToString() != "")
                {
                    model.FAllowanceAmount = decimal.Parse(row["FAllowanceAmount"].ToString());
                }
                if (row["FPolicyID"] != null)
                {
                    model.FPolicyID = row["FPolicyID"].ToString();
                }
                if (row["FIssueID"] != null)
                {
                    model.FIssueID = row["FIssueID"].ToString();
                }
                if (row["NSRBM"] != null)
                {
                    model.NSRBM = row["NSRBM"].ToString();
                }
                if (row["YBTJE"] != null && row["YBTJE"].ToString() != "")
                {
                    model.YBTJE = decimal.Parse(row["YBTJE"].ToString());
                }
                if (row["se"] != null && row["se"].ToString() != "")
                {
                    model.se = decimal.Parse(row["se"].ToString());
                }
            }
            return model;
        }

        /// <summary>
        /// 获得数据列表
        /// </summary>
        public DataSet GetList(string strWhere)
        {
            StringBuilder strSql = new StringBuilder();
            strSql.Append(@"select [FTaxAuditId]
                                ,[FEntityNo]
                                ,[FAllowanceClassNo]
                                ,[NSRDZDAH]
                                ,[RKRQ_Q]
                                ,[RKRQ_Z]
                                ,[NSRMC]
                                ,[FOldEnterprisePropNo]
                                ,[FOldFinancePropNo]
                                ,[FNewEnterprisePropNo]
                                ,[FNewFinancePropNo]
                                ,[FStatus]
                                ,[FNote]
                                ,[FPolicyNote]
                                ,[FIsReturn]
                                ,[FInsEmpNo]
                                ,[FInsDeptNo]
                                ,[FInsDate]
                                ,[FInsIP]
                                ,[FUpdEmplNo]
                                ,[FUpdDeptNo]
                                ,[FUpdDate]
                                ,[FUpdIP]
                                ,[FAllowanceName]
                                ,[FTaxClassAllowanceName]
                                ,[FYear]
                                ,[FTaxClassAllowanceNo]
                                ,[FBaseAmount]
                                ,[FAllowanceType]
                                ,[FInnerRate]
                                ,[FOuterRate]
                                ,[FAllowanceAmount]
                                ,[FPolicyID]
                                ,[FIssueID]
                                ,[NSRBM]
                                ,[YBTJE]
                                ,[se] ");
            strSql.Append(" FROM  fund.v_TaxAuditPolicyEval ");
            if (strWhere.Trim() != "")
            {
                strSql.Append(" where " + strWhere);
            }
            return DbHelperSQL.Query(strSql.ToString());
        }

        /// <summary>
        /// 获得数据列表
        /// </summary>
        public DataSet GetAllowanceCalcManageList(string strWhere)
        {
            StringBuilder strSql = new StringBuilder();
            strSql.Append(@"select  FTaxAuditId ,
          FEntityNo ,
          FAllowanceClassNo ,
          NSRDZDAH ,
          NSRMC ,
          FNewEnterprisePropNo ,
          FNewFinancePropNo ,
          FNote ,
          FAllowanceName ,
          FTaxClassAllowanceName ,
          FYear ,
          FTaxClassAllowanceNo ,
          FBaseAmount ,
          FAllowanceType ,
          FInnerRate ,
          FOuterRate ,
          FAllowanceAmount ,
          FPolicyID ,
          FIssueID ,
          NSRBM ,
          YBTJE ,
          se,
          BTJE,FAllowanceIssueEntryID,evalFStatus,FStatus");
            strSql.Append(" FROM   fund.v_AllowanceCalcManage ");
            if (strWhere.Trim() != "")
            {
                strSql.Append(" where " + strWhere);
            }
            return DbHelperSQL.Query(strSql.ToString());
        }

        /// <summary>
        /// 获得前几行数据
        /// </summary>
        public DataSet GetList(int Top, string strWhere, string filedOrder)
        {
            StringBuilder strSql = new StringBuilder();
            strSql.Append("select ");
            if (Top > 0)
            {
                strSql.Append(" top " + Top.ToString());
            }
            strSql.Append(" FTaxAuditId,FEntityNo,FYear,FAllowanceClassNo,NSRDZDAH,RKRQ_Q,RKRQ_Z,NSRMC,FOldEnterprisePropNo,FOldFinancePropNo,FNewEnterprisePropNo,FNewFinancePropNo,FStatus,FNote,FPolicyNote,FIsReturn,FInsEmpNo,FInsDeptNo,FInsDate,FInsIP,FUpdEmplNo,FUpdDeptNo,FUpdDate,FUpdIP,FAllowanceName,FTaxClassAllowanceName,NSRBM,YBTJE ");
            strSql.Append(" FROM  fund.v_TaxAuditPolicyEval ");
            if (strWhere.Trim() != "")
            {
                strSql.Append(" where " + strWhere);
            }
            strSql.Append(" order by " + filedOrder);
            return DbHelperSQL.Query(strSql.ToString());
        }

        /// <summary>
        /// 获取记录总数
        /// </summary>
        public int GetRecordCount(string strWhere)
        {
            StringBuilder strSql = new StringBuilder();
            strSql.Append("select count(1) FROM  fund.v_TaxAuditPolicyEval ");
            if (strWhere.Trim() != "")
            {
                strSql.Append(" where " + strWhere);
            }
            object obj = DbHelperSQL.GetSingle(strSql.ToString());
            if (obj == null)
            {
                return 0;
            }
            else
            {
                return Convert.ToInt32(obj);
            }
        }
        /// <summary>
        /// 分页获取数据列表
        /// </summary>
        public DataSet GetListByPage(string strWhere, string orderby, int startIndex, int endIndex)
        {
            StringBuilder strSql = new StringBuilder();
            strSql.Append("SELECT * FROM ( ");
            strSql.Append(" SELECT ROW_NUMBER() OVER (");
            if (!string.IsNullOrEmpty(orderby.Trim()))
            {
                strSql.Append("order by T." + orderby);
            }
            else
            {
                strSql.Append("order by T.FTaxAuditId desc");
            }
            strSql.Append(")AS Row, T.*  from  fund.v_TaxAuditPolicyEval T ");
            if (!string.IsNullOrEmpty(strWhere.Trim()))
            {
                strSql.Append(" WHERE " + strWhere);
            }
            strSql.Append(" ) TT");
            strSql.AppendFormat(" WHERE TT.Row between {0} and {1}", startIndex, endIndex);
            return DbHelperSQL.Query(strSql.ToString());
        }

        /*
        /// <summary>
        /// 分页获取数据列表
        /// </summary>
        public DataSet GetList(int PageSize,int PageIndex,string strWhere)
        {
            SqlParameter[] parameters = {
                    new SqlParameter("@tblName", SqlDbType.VarChar, 255),
                    new SqlParameter("@fldName", SqlDbType.VarChar, 255),
                    new SqlParameter("@PageSize", SqlDbType.Int),
                    new SqlParameter("@PageIndex", SqlDbType.Int),
                    new SqlParameter("@IsReCount", SqlDbType.Bit),
                    new SqlParameter("@OrderType", SqlDbType.Bit),
                    new SqlParameter("@strWhere", SqlDbType.VarChar,1000),
                    };
            parameters[0].Value = "v_TaxAuditPolicyEval";
            parameters[1].Value = "FTaxAuditId";
            parameters[2].Value = PageSize;
            parameters[3].Value = PageIndex;
            parameters[4].Value = 0;
            parameters[5].Value = 0;
            parameters[6].Value = strWhere;	
            return DbHelperSQL.RunProcedure("UP_GetRecordByPage",parameters,"ds");
        }*/

        #endregion  BasicMethod
        #region  ExtensionMethod

        #endregion  ExtensionMethod
    }
}

